package com.cfx.exercise_42;

import java.util.Arrays;

public class StringToInt {//将一段数字的字符串排序
	public static void main(String[] args) {
		String str = "4 6 3 5 7 9 8 1";
		System.out.println(sortString(str));
		
	}
	
	
	public static String sortString(String arr){
		
		String[] arr_num = arr.split(" ");
		StringBuilder sb = new StringBuilder();
		int [] arrInt = new int[arr_num.length];
		for (int i = 0; i < arr_num.length; i++) {
			arrInt[i] = Integer.parseInt(arr_num[i]);
		}
		Arrays.sort(arrInt);
		
		for (int i = 0; i < arrInt.length; i++) {
			if(i!=arrInt.length-1){
				sb.append(arrInt[i]+" ");
			}else{
				sb.append(arrInt[i]);
			}
		}
		return sb.toString();
	}
}
